//
//  MyMessageTwoController.m
//  Experss
//
//  Created by 嗯，大葱 on 17/7/31.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "MyMessageTwoController.h"
#import "MyMessageTwoCell.h"
#import "MyMessageDetailController.h"

@interface MyMessageTwoController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong)UITableView *tableView;

@end

@implementation MyMessageTwoController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self confTableView];//配置视图控制器
    
}
- (void)confTableView {
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height) style:(UITableViewStylePlain)];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
    _tableView.separatorStyle = kSpNone;
    _tableView.backgroundColor = KShouYeBg;
    [self.tableView registerNib:[UINib nibWithNibName:@"MyMessageTwoCell" bundle:nil] forCellReuseIdentifier:@"MyMessageTwoCell"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 35;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *bgV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, 35)];
    bgV.backgroundColor = KShouYeBg;
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,kScreen_Width, 35)];
    label.text = @"23分钟前";
    label.textColor = [UIColor grayColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = kFont12;
    [bgV addSubview:label];
    return bgV;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MyMessageTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyMessageTwoCell"];
    cell.selectionStyle = kSeNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    MyMessageDetailController *myM = [[MyMessageDetailController alloc] init];
    [self.navigationController pushViewController:myM animated:YES];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat sectionHeaderHeight = 35;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
